package com.dckxx.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dckxx.entity.StudentEntity;
import com.dckxx.mapper.StudentMapper;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

@Service
public class StudentServiceImpl extends ServiceImpl<StudentMapper, StudentEntity>  implements IStudentService {
    @Override
    public StudentEntity getStudentByName(String name) {
        List<StudentEntity> list = this.baseMapper.selectList(Wrappers.<StudentEntity>lambdaQuery().like(StudentEntity::getName, name));
        return !CollectionUtils.isEmpty(list)?list.get(0): null;
    }
}
